package com.aurora.source.authority.presenter;

import android.content.Context;

import com.aurora.source.authority.bean.ProcessDataBean;
import com.aurora.source.authority.bean.SysAuthDataBean;
import com.aurora.source.authority.view.IAddJurisdictionView;
import com.aurora.source.base.BaseBean;
import com.aurora.source.base.BasePresenter;
import com.aurora.source.constant.AuroraConstants;
import com.aurora.source.util.netutil.SubscriberObserver;

import java.util.Map;

public class AddJurisdictionPresenter extends BasePresenter<IAddJurisdictionView> {

    public AddJurisdictionPresenter(IAddJurisdictionView baseView) {
        super(baseView);
    }

    public void getFlowPermission(Context context, Map<String, String> params) {
        requestMethod.addJurisdiction(params, new SubscriberObserver<BaseBean<ProcessDataBean>>(context,"正在请求中...") {
            @Override
            public void onSuccess(BaseBean<ProcessDataBean> addJurisdictionBean) {
                if (addJurisdictionBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)) {
                    baseView.onGetFlowPermissionSuccess(addJurisdictionBean.getData());
                } else {
                    baseView.onGetFlowPermissionFail(addJurisdictionBean.getMsg());
                }
            }

            @Override
            public void onError(String msg) {
                baseView.onGetFlowPermissionFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });

    }

    public void getSysPermission(Context context, Map<String, String> params) {
        requestMethod.getSysPermission(params, new SubscriberObserver<BaseBean<SysAuthDataBean>>(context,"正在请求中...") {
            @Override
            public void onSuccess(BaseBean<SysAuthDataBean> addJurisdictionBean) {
                if (addJurisdictionBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)) {
                    baseView.onGetSysPermissionSuccess(addJurisdictionBean.getData());
                } else {
                    baseView.onGetSysPermissionFail(addJurisdictionBean.getMsg());
                }
            }

            @Override
            public void onError(String msg) {
                baseView.onGetSysPermissionFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });
    }
}
